<template>
  <el-dialog
  title="发送"
  :visible.sync="dialogVisible"
  :append-to-body="true"
  :close-on-click-modal="false"
  @close="handleColse"
  width="40%"
  >
    <el-form :model="dataForm"
             :rules="dataForm"
             ref="dataForm"
             size="small"
             label-width="80px">
      <el-form-item label="日报内容" prop="content">
        <div style="margin-top: -15px; max-height: 300px; overflow-y: auto" v-html="content"></div>
      </el-form-item>
      <el-form-item label="是否发送" prop="message">
        <el-radio-group v-model="dataForm.message" size="small" @change="handleChange">
          <el-radio label="0" border>发送</el-radio>
<!--          <el-radio label="1" border>取消</el-radio>-->
        </el-radio-group>
      </el-form-item>
      <el-form-item v-if="dataForm.message === '1'" label="备注" prop="audits">
        <el-input v-model="dataForm.audits" placeholder="请输入备注"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button
        @click="dialogVisible = false"
        size="small">取消</el-button>

      <el-button
        type="primary"
        :loading="dialogLoading"
        @click="handleSubmitForm"
        size="small">确定</el-button>
    </div>
  </el-dialog>
</template>
<script>
  import {progressCompletegl, getDaily} from '@/api/dailyweekly/workflow'
  export default {
    data() {
      return {
        dialogVisible: false,
        dialogLoading: false,
        content: '',
        dailyId: '',
        dataForm: {
          taskId: '',
          message: '0',
          audits: ''
        }
      }
    },
    methods: {
      init (val) {
        this.dialogVisible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          this.queryDaily()
        })
        this.dataForm.taskId = val.id
        this.dailyId = val.dailyId
      },
      async queryDaily () {
        const data = await getDaily(this.dailyId)
        if (data.code === 200) {
          // this.dataForm = data.data
          this.content = data.data.contentXml
        }
        this.dialogLoading = false
      },
      async addActiveList () {
        const data = await progressCompletegl(this.dataForm)
        if (data) {
          if (data.code === 200) {
            this.dialogVisible = false
            this.dialogLoading = false
            this.$emit('refreshDataList')
          } else {
            this.dialogLoading = false
          }
        }
      },
      handleSubmitForm () {
        this.dialogLoading = true
        this.addActiveList()
      },
      handleChange () {},
      handleColse () {
        this.dialogVisible = false
      }
    }
  }
</script>
